package cn.mdmbct.douyin.data.service;

import cn.mdmbct.douyin.data.api.UserData;
import cn.mdmbct.douyin.data.response.user.*;
import cn.mdmbct.douyin.common.enums.ExternalDataApiDataType;
import cn.mdmbct.douyin.common.exception.ApiCallException;
import cn.mdmbct.douyin.common.http.HttpExecutor;
import cn.mdmbct.douyin.common.service.BaseDyService;
import cn.mdmbct.douyin.common.storage.DyStorageManager;
import cn.mdmbct.douyin.data.service.interfaces.UserDataService;

/**
 * <a href="https://open.douyin.com/platform/doc/6848798450331486212">获取用户视频情况、粉丝数、点赞数、评论数、分享数、主页访问数</a>
 *
 * @author mdmbct  mdmbct@outlook.com
 * @date 2021/3/9 11:31
 * @modified mdmbct
 * @since 1.0
 */
public class UserDataServiceImpl extends BaseDyService implements UserDataService {

    public UserDataServiceImpl(DyStorageManager storageManager, HttpExecutor httpExecutor) {
        super(storageManager, httpExecutor);
    }

    @Override
    public DataUserFansRes.DataUserFansResData getUserFansCount(String openId, ExternalDataApiDataType dataType) throws ApiCallException {
        return simpleGetReqForDy(UserData.DATA_EXTERNAL_USER_FANS,
                openId,
                DataUserFansRes.DataUserFansResData.class,
                openId, dataType.getDays()
        );
    }

    @Override
    public DataUserLikeRes.DataUserLikeResData getUserLikeCount(String openId, ExternalDataApiDataType dataType) throws ApiCallException {
        return simpleGetReqForDy(UserData.DATA_EXTERNAL_USER_LIKE,
                openId,
                DataUserLikeRes.DataUserLikeResData.class,
                openId, dataType.getDays()
        );
    }

    @Override
    public DataUserCommentRes.DataUserCommentResData getUserCommentCount(String openId, ExternalDataApiDataType dataType) throws ApiCallException {
        return simpleGetReqForDy(UserData.DATA_EXTERNAL_USER_COMMENT,
                openId,
                DataUserCommentRes.DataUserCommentResData.class,
                openId, dataType.getDays()
        );
    }

    @Override
    public DataUserShareRes.DataUserShareResData getUserShareCount(String openId, ExternalDataApiDataType dataType) throws ApiCallException {
        return simpleGetReqForDy(UserData.DATA_EXTERNAL_USER_SHARE,
                openId,
                DataUserShareRes.DataUserShareResData.class,
                openId, dataType.getDays()
        );
    }

    @Override
    public DataUserProfileRes.DataUserProfileResData getUserProfileCount(String openId, ExternalDataApiDataType dataType) throws ApiCallException {
        return simpleGetReqForDy(UserData.DATA_EXTERNAL_USER_PROFILE,
                openId,
                DataUserProfileRes.DataUserProfileResData.class,
                openId, dataType.getDays()
        );
    }
}
